#ifdef _TEST_C_
#include "Spline.h"

double C_f(double x)
{
	return 1 / (1 + x * x);
}

// f' = -2x / (1+x^2)^2

void B3_spline(int N)
{
	INTERPC interpC;
	for (int i = 0; i < N; i++)
	{
		double x = -5 + i;
		interpC.points.push_back(x);
		interpC.interpSites[x] = {C_f(x)};
	}

	interpC.interpSites[-5].push_back(10.0 / 26 / 26);
	interpC.interpSites[5].push_back(-10.0 / 26 / 26);

	Spline<1, 3, ppForm> spline = interpolate<3, cardinalB>(interpC, complete);
	//spline.plot('b');
	cout << spline << endl;
}

void B2_spline(int N)
{
	INTERPC interpC;
	interpC.points.push_back(-5);
	interpC.interpSites[-5] = {C_f(-5)};

	for (int i = 0; i < N; i++)
	{
		double x = -9.0 / 2 + i;
		interpC.points.push_back(x);
		interpC.interpSites[x] = {C_f(x)};
	}

	interpC.points.push_back(5);
	interpC.interpSites[5] = {C_f(5)};

	Spline<1, 2, ppForm> spline = interpolate<2, cardinalB>(interpC, notAknot);
	//spline.plot('b');
	cout << spline << endl;
}

int main()
{
	//cout << "x = linspace(-5, 5);" << endl;
	//cout << "plot(x, 1./(1+x.^2), 'r');" << endl;
	//cout << "hold on;" << endl;

	B3_spline(11);
	B2_spline(10);

	return 0;
}

#endif
